﻿@model MyPS.Areas.Manage.Models.UserRoleModel
<fieldset>
    <legend>角色分配</legend>
    <div class="editor-label">
        用户ID
    </div>
    <div class="editor-field">
        @Html.TextBox("user", Model.UserID, new { disabled = "disabled" })
    </div>
    @using (Html.BeginForm("AddRole", "ManageUsers"))
    { 
        @Html.AntiForgeryToken()
        @Html.HiddenFor(m => m.UserID)

        if (Model.RoleList.Count() > 0)
        { 
        <div class="editor-label">
            可分配角色列表
        </div>
        <div class="editor-field">
            <select name="RoleID">
                @foreach (var item in Model.RoleList)
                { 
                    <option value="@item.RoleID">@item.Descr</option>
                }
            </select>
        </div>
        <p>
            <input type="submit" value="分配角色" />
        </p>
        }
        else
        { 
        <div class="editor-label">
            无可分配的角色
        </div>
        }


    }
</fieldset>
<fieldset>
    <legend>已分配角色列表</legend>
    <table class="tableBorder">
        <tr>
            <th>
                用户ID
            </th>
            <th>
                角色名
            </th>
            <th>
                角色描述
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model.ExsistRoleList)
        { 
            <tr>
                <td>@item.UserID
                </td>
                <td>@item.RoleID
                </td>
                <td>@item.Descr
                </td>
                <td>
                    @Html.ActionLink("移出角色", "RemoveRole", new { userid = item.UserID, roleid = item.RoleID })
                </td>
            </tr>
        }
    </table>
</fieldset>
